//
//  BRQRScanModel.m

//
//  Created by 甘卫国 on 2024/6/21.
//

#import "BRQRScanModel.h"
#import "BRCouponsListViewController.h"

@implementation BRQRScanModel

@end

@implementation BRScanFunc

+ (void)req_qrOfType:(NSInteger)type code:(NSString *)code succ:(BRDicBlock)succ fail:(BRVoidBlock)fail {
    
    NSString *url = [BRAPI codeScanRedeem];
 
    [BRHud showHud];
    [[BRRequestManager shared] GET:url params:@{@"code":code,@"type":@(type)} succeed:^(NSDictionary * _Nonnull dataDict, NSInteger respCode) {
        
        if (succ) {
            succ(dataDict);
        }
        [BRHud hidden];
        [BRHud showAuto:[BRScanFunc br_codeOfStr:type]];
        
        
    } failed:^(NSInteger code, NSString * _Nonnull errMsg) {
        
        if (fail) fail();
        [BRHud hidden];
    }];
}

+ (void)push_vc:(NSInteger)vcType by:(UIViewController *)vc {
    
   
    BRCouponsListViewController *pushVC = [[BRCouponsListViewController alloc] init];
    pushVC.vcIn = 2;
    if (vcType == 2) {
        pushVC.scanTypeIn = 1;
    }
    [vc.navigationController pushViewController:pushVC animated:YES];
    
}

+ (NSString *)br_codeOfStr:(NSInteger)type {
    
    if (type == 1) {
        return Localized(@"charge_couponTips");
    }
    if (type == 2) {
        return Localized(@"charge_promoTips");
    }
    
    return Localized(@"charge_cardTips");
}


@end
